{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<div class="chart-wrapper single-chart-grid" data-test-clients-attribution={{this.noun}}>
  <div class="chart-header has-bottom-margin-m">
    <h2 class="chart-title" data-test-attribution-title>{{capitalize this.noun}} attribution</h2>
    <p class="chart-description" data-test-attribution-description>{{this.chartText.description}}</p>
  </div>
  {{#if @attribution}}
    <div class="chart-container-wide" data-test-chart-container={{this.noun}}>
      <Clients::HorizontalBarChart @dataset={{this.topTenAttribution}} @chartLegend={{this.attributionLegend}} />
    </div>
    <div class="chart-subTitle">
      <p class="chart-subtext" data-test-attribution-subtext>{{this.chartText.subtext}}</p>
    </div>

    <div class="data-details-top" data-test-top-attribution>
      <h3 class="data-details">Top {{this.noun}}</h3>
      <p class="data-details is-word-break">{{this.topAttribution.label}}</p>
    </div>

    <div class="data-details-bottom" data-test-attribution-clients>
      <h3 class="data-details">Clients in {{this.noun}}</h3>
      <p class="data-details">{{format-number this.topAttribution.clients}}</p>
    </div>

    <div class="legend">
      {{#each this.attributionLegend as |legend idx|}}
        <span class="legend-colors dot-{{idx}}"></span><span class="legend-label">{{capitalize legend.label}}</span>
      {{/each}}
    </div>
  {{else}}
    <div class="chart-empty-state">
      <EmptyState @icon="skip" @title="No data found" @bottomBorder={{true}} />
    </div>
  {{/if}}
  <div class="timestamp" data-test-attribution-timestamp>
    {{#if @responseTimestamp}}
      Updated
      {{date-format @responseTimestamp "MMM d yyyy, h:mm:ss aaa" withTimeZone=true}}
    {{/if}}
  </div>
</div>